﻿@{
    ViewBag.Title = "设备档案管理";
    Layout = "~/Views/Shared/_ManufactureList.cshtml";
}
<link href="~/Content/css/BlankingcardManagement_print.css" rel="stylesheet" media="print" />
<style type="text/css">
    #print {
        display: none;
    }

    .tool_c {
        padding: 10px 0;
    }

    .btn-group {
        padding: 0 10px 0 0;
    }

    /*.grid_list_1_c {
        overflow: hidden;
    }

        .grid_list_1_c .frozen-bdiv {
            top: 51px !important;
        }

        .grid_list_1_c .frozen-div {
            height: 4.2em !important;
        }

        .grid_list_1_c .ui-jqgrid-hdiv {
            width: 1900px !important;
            background-color: transparent !important;
        }

        .grid_list_1_c .ui-jqgrid-bdiv {
            width: 1900px !important;
            background-color: transparent !important;
        }

        .grid_list_1_c .ui-jqgrid-btable {
            background-color: #fff !important;
        }

    .btn-group:last-child a.btn:first-child {
        margin: 0 0.5em 0 0 !important;
    }*/

    .input_inline input {
        display: inline-block;
        width: 4em;
    }

    .grid_list_1_c td:nth-child(3) a:visited, .grid_list_1_c td:nth-child(3) a:link {
        text-decoration: underline;
    }

    .grid_list_1_c td:nth-child(3) a:hover {
        text-decoration: underline;
        color: #c00;
    }

    .grid_list_1_c td:nth-child(3) a[disabled] {
        color: #ccc;
        text-decoration: line-through;
    }


    .grid_list_1_c .ui-jqgrid .ui-jqgrid-view {
        position: relative;
        left: 0;
        top: 0;
        padding: 0;
        overflow: hidden;
    }

    .btn-group input {
        height: 2em !important;
    }

    .grid_list_1_c a[disabled] {
        pointer-events: none;
        cursor: not-allowed;
        filter: alpha(opacity=65);
        -webkit-box-shadow: none;
        box-shadow: none;
        opacity: .65;
    }
</style>
<script>
    $(function () {
        Index.init();
    });

    var Index = {
        dataList: null,
        selected: [],
        page: 1,
        curSelected:-1,
        init: function () {
            with (Index) {
                initControl();

                loadDataList();
            }
        },
        initControl: function () {
            !!$.request("page") && (Index.page = $.request("page"));

            $("#gridList1").delegate("[type=checkbox]", "click", function () {
                var cur = $(this);

                var foo = cur.is(":checked");

                foo && (function () {
                    var val = $.grep(Index.selected, function (n, i) {
                        return n.id == cur.val();
                    });

                    !val[0] && Index.selected.push({ id: cur.val(), status: cur.attr("status") });
                })();

                foo || (function () {
                    var val = $.grep(Index.selected, function (n, i) {
                        return n.id == cur.val();
                    });

                    !!val[0] && Index.selected.splice(Index.selected.indexOf(val[0]), 1);
                })();
            });

            $('select').bindSelect();
            //使用单位数据
            $(".EquipUnit").bindSelect({
                url: "/BaseData/EquipmentArchive/GetUseUnitData",
                id: "MakeLineNO",
                text: "MakeLineNOMakeLineShortName"
            });
            //使用车间数据
            $(".EquipWorkshop").bindSelect({
                url: "/BaseData/EquipmentArchive/GetUseUnitData",
                id: "MakeLineNO",
                text: "MakeLineNOMakeLineShortName"
            });
            //制造单位数据
            $(".ManuUnit").bindSelect({
                url: "/BaseData/ZSJ_B1_GH_SI/GetGridJson?isProduct=1",
                id: "UnitNO",
                text: "UnitNOShortName"
            });
            //批次查询 btn_search1
            $("#btn_search1").on("click", function () {
                var $gridList1 = $("#gridList1");

                var conn1 = $.buildPostParam("EquipNO,EquipModel,EquipName,EquipUnit,EquipWorkshop,ManuUnit,EquipType", "1");

                $gridList1.jqGrid('setGridParam', {
                    postData: conn1,
                }).trigger('reloadGrid');
            });

            $("#butnGoAdd1").on("click", function () {
                var url = "/BaseData/EquipmentArchive/EquipmentArchiveAdd";

                $.modalOpen({
                    url: url,
                    width: "1280px",
                    height: "700px",
                    close: false,
                    btn: [],
                    id:"dlgEquipmentAdd",
                    callBack: function () {
                        $("#btn_search1").trigger("click");
                    }
                });
            });

            $("#gridList1").delegate("[编辑]", "click", function () {
                var jsonData = { id: $(this).attr("编辑") };

                jsonData["page"] = $("#gridList1").jqGrid("getGridParam", "page");

                jsonData["idx"] = $(this).parents("tr").attr("id");

                var url = "/BaseData/EquipmentArchive/EquipmentArchiveAdd?{0}".format($.param(jsonData));

                $.modalOpen({
                    url: url,
                    width: "1280px",
                    height: "700px",
                    close: true,
                    btn: [],
                    id: "dlgEquipmentAdd",
                    callBack: function () {
                    }
                });
            });

            $(".grid_list_1_c").delegate("[删除]", "click", function () {
                var jsonData = { id: $(this).attr("删除") };
                //当disabled属性存在时不执行删除。
                !!$(this).attr("disabled") || (function () {
                    $.modalConfirm("是否确定删除此条记录？", function (foo) {
                        foo && (function () {
                            $.post("/BaseData/EquipmentArchive/DeleteEquipmentArchive", jsonData, function (res) {
                                0 < res && (function () {
                                    $("#btn_search1").trigger("click");
                                })();
                            });
                        })();
                    }, true);
                })();
            });

            $("#butnPublish1").on("click", function () {
                !!Index.selected.length || $.modalAlert("请选择需要发布的记录。", "error");

                !!Index.selected.length && (function () {
                    var ids = [], jsonData = { type: 1, ids: "" };

                    for (var idx in Index.selected) {
                        "2" != Index.selected[idx].status && ids.push(Index.selected[idx].id);
                    }

                    jsonData.ids = ids.join(",");

                    $.post("/BaseData/EquipmentArchive/ChangeEquipmentArchive", jsonData, function (res) {
                        0 < res && (function () {
                            $.modalAlert("发布成功！", "success");

                            $("#btn_search1").trigger("click");
                        })();
                    });
                })();
            });

            $("#butnForzen1").on("click", function () {
                !!Index.selected.length || $.modalAlert("请选择需要冻结的记录。", "error");

                !!Index.selected.length && (function () {
                    var ids = [], jsonData = { type: 2, ids: "" };

                    for (var idx in Index.selected) {
                        "1" == Index.selected[idx].status && ids.push(Index.selected[idx].id);
                    }

                    jsonData.ids = ids.join(",");

                    $.post("/BaseData/EquipmentArchive/ChangeEquipmentArchive", jsonData, function (res) {
                        0 < res && (function () {
                            $.modalAlert("冻结成功！", "success");

                            $("#btn_search1").trigger("click");
                        })();
                    });
                })();
            });

            $("#butnExport1").on("click", function () {
                var param = { id: "V_Equ_11_DA_CEquipInfo", param: Index.buildExportConn("EquipNO,EquipModel,EquipName,EquipUnit,EquipWorkshop,ManuUnit".split(","), "1") };

                var url = "/Common/ExcelExportById?{0}".format($.param(param));

                location.href = url;
            });

        },
        buildExportConn: function (params, num) {
            var conn = "";

            !num && (num = "");

            params.forEach(function (item) {
                var val = $("#{0}{1}".format(item, num)).val();

                !!val && (conn += ("and {0} = '{1}'".format(item, val)));
            });

            return conn;
        },
        loadDataList: function () {
            var onSelectedFormat = function (cellvalue, options, rowObject) {
                var vals = cellvalue.split(',');

                return "<input type=\"checkbox\" status=\"{1}\" value=\"{0}\"/>".format(vals[1], vals[0]);
            };

            var onEditFormat = function (cellvalue, options, rowObject) {

                var vals = cellvalue.split(',');

                var obj = { id: vals[1], status: (0 == vals[0] ? "" : "disabled") };

                var template = "<a href=\"javascript:void(0);\"  编辑=\"{id}\">编辑</a>&nbsp;<a  href=\"javascript:void(0);\"  删除=\"{id}\" {status}>删除</a>";

                return template.format(obj);
            };

            var conn1 = $.buildPostParam("EquipNO,EquipModel,EquipName,EquipUnit,EquipWorkshop,ManuUnit", "1");
            var $gridList1 = $("#gridList1");
            $gridList1.dataGridForJson({
                url: "/BaseData/EquipmentArchive/GetEquipmentArchivies",
                postData: conn1,
                height: $(window).height() - 220,
                page:Index.page,
                colModel: [
                { label: '选择', name: 'MaintainStatusID', width: 40, align: 'center', sortable: false, frozen: true, formatter: onSelectedFormat, frozen: true },
                { label: '操作', name: 'MaintainStatusID', width: 80, align: 'center', sortable: false, frozen: true, formatter: onEditFormat, frozen: true },
                { label: '维护<br/>状态', name: 'MaintainStatusName', width: 40, align: 'center', sortable: false, frozen: true },
                { label: 'ID(隐藏)', name: 'EquipID', width: 40, align: 'center', sortable: false, frozen: true, hidden: true },
                { label: '生产单位', name: 'EquipUnit', width: 160, align: 'left', sortable: false, frozen: true, hidden: true },
                { label: '生产单位名称', name: 'EquipUnitName', width: 160, align: 'left'},
                { label: '生产车间', name: 'EquipWorkshop', width: 120, align: 'left', sortable: false, hidden: true },
                 { label: '生产车间', name: 'EquipWorkshopName', width: 160, align: 'left'},
                { label: '设备编号', name: 'EquipNO', width: 240, align: 'left' },
                { label: '设备名称', name: 'EquipName', width: 160, align: 'left', sortable: false },
                { label: '设备型号', name: 'EquipModel', width: 160, align: 'left', sortable: false },
               { label: 'JF/DF', name: 'JFDF', width: 80, align: 'left', sortable: false },
                { label: '设备线位（隐藏）', name: 'EquipLine', width: 80, align: 'right', sortable: false, formatter: 'number', hidden: true },
                { label: '设备线位', name: 'EquipLineName', width: 80, align: 'left', sortable: false },
                { label: '设备类别(隐藏)', name: 'EquipType', width: 80, align: 'right', sortable: false, hidden: true },
                { label: '设备类别', name: 'EquipTypeName', width: 80, align: 'center', sortable: false },
                { label: '位置号', name: 'PositionNumber', width: 80, align: 'left', sortable: false },
                { label: '资产编号', name: 'AssetNumber', width: 160, align: 'left' },
                { label: '制造单位（隐藏）', name: 'ManuUnit', width: 80, align: 'right', sortable: false, hidden: true },
                { label: '制造单位', name: 'ManuUnitName', width: 160, align: 'left', sortable: false },
                { label: '设备数量', name: 'EquNumber', width: 80, align: 'right', sortable: false },
                 { label: '出厂编号', name: 'manufactNo', width: 120, align: 'left', sortable: false },
                { label: '启用日期', name: 'EnableDate', width: 80, align: 'right', sortable: false },
                { label: '设备原值<br/>(万元)', name: 'EquValue', width: 80, align: 'right', sortable: false },
                { label: '折旧年限<br/>（年）', name: 'DepreYears', width: 80, align: 'right', sortable: false },
                { label: '使用情况', name: 'UseSituation', width: 80, align: 'center', sortable: false },
                { label: '用途情况', name: 'EffectSituation', width: 80, align: 'center', sortable: false },
                { label: '备注说明', name: 'MoldExplain', width: 160, align: 'left', sortable: false },
                { label: '公程压力<br/>(KN)', name: 'CY_EngPressure', width: 120, align: 'right', sortable: false },
                { label: '公程压力行程<br/>(mm)', name: 'CY_EngPreTrip', width: 120, align: 'right', sortable: false },
                 { label: '最大闭合高度<br/>(mm)', name: 'CY_MaxCloseHei', width: 120, align: 'right', sortable: false },
                { label: '最大装模高度<br/>(mm)', name: 'CY_MaxLoadModeHei', width: 120, align: 'right', sortable: false },
                 { label: '装模高度调节量', name: 'CY_LoadMoleReguHei', width: 120, align: 'right', sortable: false },
                 { label: '垫板厚度', name: 'CY_PlateThick', width: 80, align: 'right', sortable: false },
                { label: '滑块行程间隔', name: 'CY_SlideTripNum_Space', width: 120, align: 'right', sortable: false },
                 { label: '滑块行程次数<br/>(次/分)', name: 'CY_SlideTripNum', width: 120, align: 'right', sortable: false },
                 { label: '滑块行程<br/>(mm)', name: 'CY_SlideTrip', width: 160, align: 'right', sortable: false },
                { label: '工作台面尺寸', name: 'CY_TableSize', width: 120, align: 'right', sortable: false },
                { label: '滑块底面尺寸', name: 'CY_SlideBotSize', width: 120, align: 'right', sortable: false },
                { label: '打杆数量', name: 'CY_HitbarsNum', width: 80, align: 'right', sortable: false },
                 { label: '打杆行程<br/>(mm)', name: 'CY_HitbarTrip', width: 80, align: 'right', sortable: false },
                 { label: '气垫数量', name: 'CY_AirCushNum', width: 80, align: 'right', sortable: false },
                 { label: '气垫行程<br/>(mm)', name: 'CY_AirCushTrip', width: 80, align: 'right', sortable: false },
                { label: '气垫压力<br/>(KN)', name: 'CY_AirCushPressure', width: 80, align: 'right', sortable: false },
                { label: '设备重量<br/>(吨)', name: 'CY_EngWeight', width: 80, align: 'right', sortable: false },
                { label: '顶杆孔位尺寸', name: 'CY_TopRodHoleSize', width: 120, align: 'right', sortable: false },
                 { label: '附属电机数量', name: 'CY_SubElecSum', width: 120, align: 'right', sortable: false },
                { label: '附属电机功率<br/>(W)', name: 'CY_SubElecPower', width: 120, align: 'right', sortable: false },
                 { label: '可剪板宽', name: 'JQ_PlateWidth', width: 80, align: 'right', sortable: false },
                 { label: '可剪板厚', name: 'JQ_PlateThick', width: 80, align: 'right', sortable: false },
                { label: '可加工板宽', name: 'KJ_PlateWidth', width: 120, align: 'right', sortable: false },
                 { label: '可加工板厚', name: 'KJ_PlateThick', width: 120, align: 'right', sortable: false },
                 { label: '剪切材料强度', name: 'KJ_MStrength', width: 120, align: 'right', sortable: false },
                { label: '允许钢卷内径', name: 'KJ_Inradium', width: 120, align: 'right', sortable: false },
                { label: '允许钢卷外径', name: 'KJ_Extadium', width: 120, align: 'right', sortable: false },
                { label: '开卷机最大载重量', name: 'KJ_KJJLoadWeight', width: 120, align: 'right', sortable: false },
                 { label: '升降台最大载重量<br/>(吨)', name: 'KJ_SJJLoadWeight', width: 120, align: 'right', sortable: false },
                 { label: '剪切长度范围', name: 'KJ_LengthRange', width: 120, align: 'right', sortable: false },
                 { label: '材料厚度', name: 'QX_MThick', width: 80, align: 'right', sortable: false },
                { label: '材料宽度', name: 'QX_MWidth', width: 80, align: 'right', sortable: false },
                { label: '材料长度', name: 'QX_MLength', width: 80, align: 'right', sortable: false },
                { label: '料片最大重量<br/>（kg）', name: 'QX_LPMaxWeight', width: 120, align: 'right', sortable: false },
                 { label: '料垛最大重量<br/>（kg）', name: 'QX_LDMaxWeight', width: 120, align: 'right', sortable: false },
                { label: '油膜厚度<br/>( g/m2)', name: 'QX_OilFilm', width: 80, align: 'right', sortable: false },
                 { label: '过滤精度<br/>（um）', name: 'QX_FiltAccu', width: 80, align: 'right', sortable: false },
                 { label: '清洗精度<br/>（um）', name: 'QX_CleanAccuracy', width: 80, align: 'right', sortable: false },
                { label: '天车小车主动轮径<br/>(mm)', name: 'TC_ZQSQZL', width: 120, align: 'right', sortable: false },
                 { label: '天车小车被动轮径<br/> (mm)', name: 'TC_XCBDLJ', width: 120, align: 'right', sortable: false },
                 { label: '天车主起升起重量<br/>(T)', name: 'TC_ZQSQZL', width: 120, align: 'right', sortable: false },
                { label: '天车副起升起重量<br/>(T)', name: 'TC_FQSQZL', width: 120, align: 'right', sortable: false },
                { label: '天车主起升最大起升高度<br/>(m)', name: 'TC_ZQSZDSQGD', width: 120, align: 'right', sortable: false },
                { label: '天车副起升最大起升高度<br/>(m)', name: 'TC_FQSZDSQGD', width: 120, align: 'right', sortable: false },
                 { label: '天车主起升卷筒直径<br/>(mm)', name: 'TC_ZQSJTZJ', width: 120, align: 'right', sortable: false },
                 { label: '天车副起升卷筒直径<br/>(mm)', name: 'TC_FQSJTZJ', width: 120, align: 'right', sortable: false },
                 { label: '天车大车主动轮径<br/>(mm)', name: 'TC_DCZDLJ', width: 120, align: 'right', sortable: false },
                { label: '电葫芦大车主动轮径<br/>(mm)', name: 'DHL_DCZDLJ', width: 120, align: 'right', sortable: false },
                { label: '电葫芦大车被动轮径<br/>(mm)', name: 'DHL_DCBDLJ', width: 120, align: 'right', sortable: false },
                { label: '电葫芦起升起重量<br/>(T)', name: 'DHL_QSQZL', width: 120, align: 'right', sortable: false },
                 { label: '电葫芦最大起升高度<br/>(m)', name: 'DHL_ZDQSGD', width: 120, align: 'right', sortable: false },
                { label: '创建人员', name: 'InputUser', width: 80, align: 'center', sortable: false },
                 { label: '创建日期', name: 'InputDate', width: 80, align: 'center', sortable: false },
                 { label: '创建时间', name: 'InputTime', width: 80, align: 'center', sortable: false },
                { label: '发布人员', name: 'FAuditingBy', width: 80, align: 'center', sortable: false },
                 { label: '发布日期', name: 'FAuditingDate', width: 80, align: 'center', sortable: false },
                 { label: '发布时间', name: 'FAuditingTime', width: 80, align: 'center', sortable: false }
                ],
                pager: "#gridPager1",
                sortname: 'UseUnit,EquipNO',
                sortorder:"asc",
                viewrecords: true,
                rownumWidth: 50,
                onSelectRow: function (rowId) {

                },
                loadComplete: function (data) {
                    Index.dataList = data;

                    Index.selected = [];

                    !!$.request("idx") && (Index.curSelected = $.request("idx"));

                    -1 != Index.curSelected && $("#gridList1").jqGrid('setSelection', Index.curSelected);
                }
            });

            $gridList1.jqGrid('setFrozenColumns');
        }
    };



</script>
<div class="layout" id="layout" style="height: 100%; width: 100%;">
    <div class="tool_c">
        <div class="btn-group input-width-185">
            &nbsp;设备编号<br />
            <input id="EquipNO1" name="" placeholder="" type="text" class="form-control required" />
        </div>
        <div class="btn-group input-width-185">
            &nbsp;设备型号<br />
            <input id="EquipModel1" name="" placeholder="" type="text" class="form-control required" />
        </div>
        <div class="btn-group input-width-185">
            &nbsp;设备名称<br />
            <input id="EquipName1" name="" placeholder="" type="text" class="form-control required" />
        </div>
        <div class="btn-group input-width-185">
            &nbsp;使用单位<br />
            <select id="EquipUnit1" class="sel_common EquipUnit">
                <option value="">请选择</option>
            </select>
        </div>
        <div class="btn-group input-width-185">
            &nbsp;使用车间<br />
            <select id="EquipWorkshop1" class="sel_common EquipWorkshop">
                <option value="">请选择</option>
            </select>
        </div>
        <div class="btn-group input-width-185">
            &nbsp制造单位<br />
            <select id="ManuUnit1" class="sel_common ManuUnit">
                <option value="">请选择</option>
            </select>
        </div>
        <div class="btn-group">
            <a id="btn_search1" class="btn btn-primary center-block"><span class="glyphicon glyphicon-search"></span>查询</a>
            <a class="btn btn-primary center-block" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span>刷新</a>
            <a id="butnGoAdd1" class="btn btn-primary center-block"><span class="glyphicon glyphicon-plus"></span>新增</a>
            <a id="butnPublish1" class="btn btn-primary center-block i1 i12"><span class="glyphicon glyphicon-flag"></span>发布</a>
            <a id="butnForzen1" class="btn btn-primary center-block"><span class="glyphicon glyphicon-lock"></span>冻结</a>
            <a id="butnExport1" class="btn btn-primary center-block"><span class="glyphicon glyphicon-export"></span>导出</a>
        </div>
    </div>
    <div class="grid_list_1_c" style="margin-top: 5px;">
        <table id="gridList1"></table>
        <div id="gridPager1"></div>
    </div>
    <div id="print1">
    </div>
</div>

